package strfmtwrap.formatter;

import java.io.DataInputStream;
import java.util.Scanner;
import java.util.regex.Pattern;

/*
 * Reading a mail from keyboard and parsing
 */
public class MyFormatterExample {
	String input;
	Scanner scan;
	
	public MyFormatterExample() {
		scan = new Scanner(System.in);
	}
	
	public void readStringFromKeyboard(){
		System.out.println("Input your string: ");
		input = scan.nextLine();
	}
	
	public boolean isMail(){
		Pattern pSpecial = Pattern.compile("[^a-zA-Z0-9@\\.]"); 
		if (pSpecial.matcher(input).find()) return false;
		
		Pattern pBegin = Pattern.compile("^[^a-zA-Z]");
		if (pBegin.matcher(input).find()) return false;

		Pattern paroba = Pattern.compile(".*@.*@.*");
		if (paroba.matcher(input).find()) return false;

		return true;
	}
	
	public static void main(String[] args) {
		MyFormatterExample me = new MyFormatterExample();
		
//		me.readStringFromKeyboard();
		
//		System.out.println(me.isMail());
		
	}
}
